﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenericValidation.Validators
{
    /// <summary>
    /// Extensibility class that defines ValidationMember extension methods that are creating (factory) default member Validators.
    /// </summary>
    public static class Utility
    {
        public static MemberValidator<T, U> IsRequired<T, U>(this ValidationMember<T, U> member)
            where T:class
        {
            return new IsRequiredValidator<T, U>(member);
        }

        public static MemberValidator<T, U> IsRequired<T, U>(this ValidationMember<T, U> member, U defaultValue)
            where T:class
        {
            return new IsRequiredValidator<T, U>(member, defaultValue);
        }

        public static MemberValidator<T, U> IsGreaterThan<T, U>(this ValidationMember<T, U> member, U minValue)
            where T:class
        {
            return new CompareValidator<T, U>(member, minValue, null);
        }

        public static MemberValidator<T, U> IsLowerThan<T, U>(this ValidationMember<T, U> member, U maxValue)
            where T:class
        {
            return new CompareValidator<T, U>(member, null, maxValue);
        }

        public static MemberValidator<T, string> IsLengthBetween<T>(this ValidationMember<T, string> member, int minLength, int maxLength)
            where T:class
        {
            return new StringLengthValidator<T>(member, minLength, maxLength);

        }

        public static MemberValidator<T, string> IsLengthLowerThan<T>(this ValidationMember<T, string> member, int maxLength)
            where T:class
        {
            return new StringLengthValidator<T>(member, null, maxLength);
        }


    }
}
